home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1993 December
/
PSL Monthly Shareware CD-ROM (December 1993).iso
/
prgmming
/
dos
/
c
/
stdlib1.exe
/
lha
/
LSIZE.ASM
< prev
next >
Wrap
Assembly Source File
|
1990-04-29
|
2KB
|
106 lines
stdlib segment para public 'slcode'
assume cs:stdlib
;
; LSize- Returns the number of print positions required by an integer value.
; On Input:
; DX:AX- Integer to get the size of.
;
; On Output:
; AX: Digit count for the integer.
;
public sl_LSize
sl_LSize proc far
push dx
cmp dx, 0
jge LSize2
;
; Negate DX:AX
;
neg dx
neg ax
sbb dx, 0
;
call GetULSize
inc ax
pop dx
ret
;
LSize2: call GetULSize
pop dx
ret
sl_LSize endp
;
; USize- Same as above, except for unsigned numbers.
;
public sl_ULSize
sl_ULSize proc far
call GetULSize
ret
sl_ULSize endp
;
; GetUSize- Does the actual size comparison.
;
GetULSize proc near
cmp dx, 0
jne GUSA
;
cmp ax, 10
ja GUS1
mov ax, 1
ret
;
GUS1: cmp ax, 100
ja GUS2
mov ax, 2
ret
;
GUS2: cmp ax, 1000
ja GUS3
mov ax, 3
ret
GUS3: cmp ax, 10000
ja GUS4
mov ax, 4
ret
;
GUS4: mov ax, 5
ret
;
GUSA: sub ax, 86a0h ;Low (100,000)
sbb dx, 1 ;High(100,000)
jb GUS5
sub ax, 0bba0h ;Low (900,000)
sbb dx, 0dh ;High(900,000)
jb GUS6
sub ax, 5440h ;low (9,000,000)
sbb dx, 89h ;high(9,000,000)
jb GUS7
sub ax, 4a80h ;low (90,000,000)
sbb dx, 55dh ;high(90,000,000)
jb GUS8
sub ax, 0e900h ;low (900,000,000)
sbb dx, 35a4h ;high(900,000,000)
jb GUS9
mov ax, 10
ret
;
GUS5: mov ax, 5
ret
;
GUS6: mov ax, 6
ret
;
GUS7: mov ax, 7
ret
;
GUS8: mov ax, 8
ret
;
GUS9: mov ax, 9
ret
;
GetULSize endp
;
stdlib ends
end